package com.jd.dlc.config;

import com.jd.dlc.limit.GaLimiter;
import com.jd.dlc.limit.LimitLoader;
import com.jd.dlc.limit.dynamic.LimiterRuleDynamic;
import com.jd.dlc.limit.fallback.backer.DefaultBacker;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;


/**
 * @program: dlc
 * @ClassName LimitConfig
 * @description:
 * @author: sizegang
 * @create: 2022-05-10
 **/
@ConditionalOnProperty(name = "dlc.limiter.enabled", havingValue = "true")
@Configuration
@ComponentScan(basePackages = "com.jd.dlc")
public class LimitConfig {

    @Bean
    DefaultBacker defaultBacker() {
        return new DefaultBacker();
    }

    @Bean
    @Scope("prototype")
    GaLimiter gaLimiter() {
        return new GaLimiter();
    }

    @Bean
    LimitLoader limitLoader() {
        return new LimitLoader();
    }

    @Bean
    LimiterRuleDynamic limiterRuleDynamic() {
        return new LimiterRuleDynamic();
    }

}
